
static char RCSId[]="$Id: OptionsPanel.m,v 1.1.1.1 1993/03/18 03:34:41 davis Exp $";



#import <appkit/Application.h>
#import <appkit/Cell.h>
#import <appkit/Matrix.h>
#import <appkit/Panel.h>
#import <appkit/Text.h>

#import "GnuplotPlot.h"
#import "OptionsPanel.h"


@interface OptionsPanel (Private)

- _updatePanel;

@end


@implementation OptionsPanel

- init
{
    [super init];
    status = nil;

    return self;
}


- panel
{
    return panel;
}



- showPanel:sender
{
    [panel makeKeyAndOrderFront:self];
    return self;
}


- forceUpdate;
{
    id mainWindow = [NXApp mainWindow];

    if (mainWindow)
	status = [[mainWindow delegate] status];
    else
	status = nil;

    [self _updatePanel];

    return self;
}


- windowDidUpdate:sender
{
    id mainWindow = [NXApp mainWindow];
    id newStatus;

    if (mainWindow)
	newStatus = [[mainWindow delegate] status];
    else
	newStatus = nil;

    if (newStatus != status) {
	status = newStatus;
	[self _updatePanel];
    }

    return self;
}


// Shuts up the compiler about unused RCSId
- (const char *) rcsid
{
    return RCSId;
}


- textDidEnd:textObject endChar:(unsigned short)whyEnd
{
    /*  
     *  Under most circumstances, the superview of the textObject is 
     *  the Cell that was being edited.  All of the TextFieldCells in 
     *  the OptionPanels, however, are assumed to be scrollable (so 
     *  the user can enter numbers larger than the space that I've 
     *  allowed), so the superview of the textObject is a ClipView.  
     *  The Cell we want is the super view of the ClipView.
     */
    id matrix = [[textObject superview] superview];
    id editCell = [matrix selectedCell];

    if (_textCellChanged && ((whyEnd == NX_TAB) || (whyEnd == NX_BACKTAB)))  {

	if ([editCell action])	/* If cell has its own action, do it	*/
	    [[editCell controlView]
		sendAction:[editCell action] to:[editCell target]];

	else			/* Otherwise, do the matrix's action	*/
	    [matrix sendAction:[matrix action] to:[matrix target]];

	_textCellChanged = NO;

    }

    return self;
}



- (BOOL) textWillChange:textObject
{
    _textCellChanged = YES;
    return NO;		/* NO means it's okay for the text to change	*/
}


@end






@implementation OptionsPanel (Private)


- _updatePanel
{
    return self;
}


@end
